using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class SO_FACILITYMap : EntityTypeConfiguration<SO_FACILITY>
    {
        public SO_FACILITYMap()
        {
            // Primary Key
            this.HasKey(t => new { t.ID, t.NAME, t.ROOM, t.COLOR, t.MINIMUM_USAGE });

            // Properties
            this.Property(t => t.ID)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.NAME)
                .IsRequired()
                .HasMaxLength(20);

            this.Property(t => t.ROOM)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.WARD)
                .HasMaxLength(20);

            this.Property(t => t.TYPE)
                .HasMaxLength(20);

            this.Property(t => t.COLOR)
                .IsRequired()
                .HasMaxLength(10);

            this.Property(t => t.GENDER)
                .HasMaxLength(11);

            this.Property(t => t.STATUS)
                .HasMaxLength(8);

            this.Property(t => t.USAGE_TYPE)
                .HasMaxLength(6);

            this.Property(t => t.MINIMUM_USAGE)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            // Table & Column Mappings
            this.ToTable("SO_FACILITY");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.NAME).HasColumnName("NAME");
            this.Property(t => t.ROOM).HasColumnName("ROOM");
            this.Property(t => t.WARD).HasColumnName("WARD");
            this.Property(t => t.TYPE).HasColumnName("TYPE");
            this.Property(t => t.COLOR).HasColumnName("COLOR");
            this.Property(t => t.GENDER).HasColumnName("GENDER");
            this.Property(t => t.STATUS).HasColumnName("STATUS");
            this.Property(t => t.USAGE_TYPE).HasColumnName("USAGE_TYPE");
            this.Property(t => t.MINIMUM_USAGE).HasColumnName("MINIMUM_USAGE");
        }
    }
}
